package com.tiankun.eurekasellgoods.service.impl;

import com.tiankun.eurekasellgoods.mapper.GoodsMapper;
import com.tiankun.eurekasellgoods.mapper.SpikeMapper;
import com.tiankun.eurekasellgoods.pojo.Goods;
import com.tiankun.eurekasellgoods.pojo.Spike;
import com.tiankun.eurekasellgoods.service.GoodsService;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA
 * User: shenhui
 * Date: 2020/11/11
 * Description
 * Version: V1.0
 */
@Service("goodsService")
public class GoodsServiceImpl implements GoodsService {
    @Resource

    GoodsMapper goodsMapper = null;

    @Resource
    SpikeMapper spikeMapper = null;


    @Override
    public List<Map<String, Object>> getList(Integer shopId) {

        List<Map<String, Object>> maps = goodsMapper.goodsList(shopId);
        return maps;

    }

    @Override
    public List<Map<String, Object>> goodsNameList(Integer shopId, String godName) {
        List<Map<String, Object>> maps = goodsMapper.goodsNameList(shopId, godName);
        return maps;
    }

    @Override
    public List<Map<String, Object>> goodsStateList(Integer shopId, Integer godState) {
        List<Map<String, Object>> maps = goodsMapper.goodsStateList(shopId, godState);
        return maps;
    }

    @Override
    public List<Map<String, Object>> goodsTypeList(Integer shopId, Integer godType) {
        List<Map<String, Object>> maps = goodsMapper.goodsTypeList(shopId, godType);
        return maps;
    }

    @Override
    public Integer delete(Integer godId) {
        Goods goods = new Goods();
        goods.setGodId(godId);
        int delete = goodsMapper.delete(goods);
        return delete;
    }

    @Override
    public Integer updateGoodsState(Integer godId, Integer godState) {
        Example example = new Example(Goods.class);
        example.createCriteria().andEqualTo("godId", godId);
        Goods goods = new Goods();
        goods.setGodState(godState);
        int i = goodsMapper.updateByExampleSelective(goods, example);
        return i;
    }

    @Override
    public Integer updateGoodsNumber(Integer godId, Integer godNumber) {
        Example example = new Example(Goods.class);
        example.createCriteria().andEqualTo("godId", godId);
        Goods goods = new Goods();
        goods.setGodNumber(godNumber);
        int i = goodsMapper.updateByExampleSelective(goods, example);
        return i;
    }

    @Override
    public List<Map<String, Object>> goodsDetails(Integer godId) {
        List<Map<String, Object>> maps = goodsMapper.goodsDetails(godId);
        return maps;
    }

    @Override
    public Integer add(Goods goods) {
        int i = goodsMapper.insertSelective(goods);
        return i;
    }

    @Override
    public List<Map<String, Object>> goodsHot() {
        List<Map<String, Object>> maps = goodsMapper.goodsHot();
        return maps;
    }

    @Override
    public List<Map<String, Object>> goodsSpike(Integer shopId) {
        List<Map<String, Object>> maps = goodsMapper.goodsSpike(shopId);
        return maps;
    }

    @Override
    public Integer updateGoods(Goods goods) {
        int i = goodsMapper.updateByPrimaryKeySelective(goods);
        return i;
    }

    @Override
    public List<Map<String, Object>> goodsSpikeDetails(Integer spkId) {
        List<Map<String, Object>> maps = goodsMapper.goodsSpikeDetails(spkId);
        return maps;
    }

    @Override
    public Integer updateSpike(Spike spike) {
        int i = spikeMapper.updateByPrimaryKeySelective(spike);
        return i;
    }

    @Override
    public List<Map<String, Object>> nameSpike(Integer shopId, String godName) {
        List<Map<String, Object>> maps = goodsMapper.nameSpike(shopId, godName);
        return maps;
    }

    @Override
    public List<Map<String, Object>> typeSpike(Integer shopId, Integer godType) {
        List<Map<String, Object>> maps = goodsMapper.typeSpike(shopId, godType);
        return maps;
    }

    @Override
    public List<Map<String, Object>> stateSpike(Integer shopId) {
        List<Map<String, Object>> maps = goodsMapper.stateSpike(shopId);
        return maps;
    }

    @Override
    public Integer insertSpike(Spike spike) {

    int insert = spikeMapper.insert(spike);
       return insert;

    }

    @Override
    public List<Map<String, Object>> moveGoodsDetails(Integer godId) {
        List<Map<String, Object>> maps = goodsMapper.moveGoodsDetails(godId);
        return maps;
    }

    @Override
    public List<Map<String, Object>> moveAscSpike() {
        List<Map<String, Object>> maps = goodsMapper.moveAscSpike();
        return maps;
    }

    @Override
    public List<Map<String, Object>> timeSpike(String startDate, String endDate) {
        List<Map<String, Object>> maps = goodsMapper.timeSpike(startDate, endDate);
        return maps;
    }

    @Override
    public Map<String, Object> getId() {
        Map<String, Object> id = goodsMapper.getId();
        return id;

    }

    @Override
    public Integer addGoodsImages(Integer godId, String giUrl) {
        int i = goodsMapper.addGoodsImages(godId, giUrl);
        return i;
    }

    @Override
    public List<Map<String, Object>> typeAll() {
        List<Map<String, Object>> maps = goodsMapper.typeAll();
        return maps;
    }

    @Override
    public Integer deleteSpike(Integer spikeId) {
        Spike spike=new Spike();
        spike.setSpkId(spikeId);
        int i = spikeMapper.deleteByPrimaryKey(spike);
        return i;
    }

    @Override
    public Integer GoodsCount(Integer godId) {
        goodsMapper.GoodsCount(godId);
        return null;
    }

    @Override
    public Map<String, Object> getSpikeId() {
        Map<String, Object> getSpikeId = goodsMapper.getSpikeId();
        return getSpikeId;
    }

    @Override
    public Map<String, Object> getSpikeRedis(Integer spikeId) {
        Map<String, Object> spikeRedis = goodsMapper.getSpikeRedis(spikeId);
        return spikeRedis;
    }
}
